package net.dodoman.proxy.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class DynamicSubject1 implements InvocationHandler {
	private Object sub;

	public Object createProxyInstance(Object sub) {
		this.sub = sub;
		return Proxy.newProxyInstance(this.sub.getClass().getClassLoader(),
				this.sub.getClass().getInterfaces(), this);
	}

	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		System.out.println("before calling " + method);
		method.invoke(sub, args);
		System.out.println("after calling " + method);
		return null;
	}
}
